package com.demo.rxjavademo.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.demo.rxjavademo.R;
import com.demo.rxjavademo.loader.FrescoImageLoader;
import com.demo.rxjavademo.mode.StoriesBean;

import java.util.List;

/**
 * Created by Administrator on 2016/12/26.
 */

public class MainAdapter extends BaseQuickAdapter<StoriesBean, BaseViewHolder> {
    FrescoImageLoader mFrescoImageLoader = null;

    public MainAdapter(int layoutResId, List<StoriesBean> data) {
        super(layoutResId, data);
        mFrescoImageLoader = new FrescoImageLoader();
    }


    @Override
    protected void convert(BaseViewHolder baseViewHolder, StoriesBean storiesBean) {
        baseViewHolder.setText(R.id.tv_news_text, storiesBean.getTitle());
        if (storiesBean.getImages().size() > 0) {
            baseViewHolder.getView(R.id.iv_news_image).setVisibility(View.VISIBLE);

            FrescoImageLoader frescoImageLoader = new FrescoImageLoader();
            frescoImageLoader.displayImage(mContext,
                    storiesBean.getImages().get(0),
                    baseViewHolder.<ImageView>getView(R.id.iv_news_image));
//            Glide.with(mContext)
//                    .load(item.getUserAvatar())
//                    .crossFade()
//                    .placeholder(R.mipmap.def_head)
//                    .transform(new GlideCircleTransform(mContext))
//                    .into((ImageView) helper
//                            .getView(R.id.tweetAvatar));
        }

    }
}
